<%@ page language="java" pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
  <head>
    <html:base />
    
    <title>roleGrant.jsp</title>
	<link href="./css/xtab.css" rel="stylesheet" type="text/css" />

  </head>
  
  <body>
  <html:form action="/role.do?method=roleGrant">
    <table cellspacing="0" width="100%" border="1">

			<tr>
				<td class="tableTitle">
					角色名称
				</td>
				<td>
					${role.roleName }
				</td>
				<td class="tableTitle">
					描述
				</td>
				<td>
					${role.description }
				</td>
			</tr>
		</table>
		<br>
		<input type="button" class="button" id="button1" value="同步权限" onclick="synPermission('${role.roleId }');">
		
		<table width="100%" cellspacing="0">
			<tr>
                <th class="tableTitle" width="10%">
                	<input type="checkbox" name="allCheck" onclick="checkAll('permissionId');"> 
                </th>
				<th class="tableTitle" width="40%">
					模块名称
				</th>
                <th class="tableTitle" width="50%">
					功能权限
				</th>
				 
			</tr>
			</table>
			<div style="overflow-y:auto;height:300px;">
			<table width="100%" cellspacing="0">
			<logic:iterate id="s" name="listPremission">
				<tr>
					<td class="tableElement" width="10%">
					<logic:equal value="0" name="s" property="isChecked">
						<input type="checkbox" name="permissionId" value="${s.permissionId }">
					</logic:equal>	
					<logic:equal value="1" name="s" property="isChecked">
						<input type="checkbox" name="permissionId" checked="checked" value="${s.permissionId }">
					</logic:equal>
					</td>
					<td class="tableElement" width="40%">
						${s.RName }
					</td>
					<td class="tableElement" width="50%">
						${s.prName }
					</td>
				</tr>
			</logic:iterate>
		</table>
		</div> 
		<html:hidden property="role.roleId" value="${role.roleId }"></html:hidden>
		<div align="center">
		<input type="button" class="button" id="button2" value="提 交" onclick="roleGrant();">
		</div>
		<script>
		function checkAll(formvalue) {  
            var roomids = document.getElementsByName(formvalue);  
           for (var j = 0; j < roomids.length; j++) {
              if(document.getElementsByName('allCheck')[0].checked==true){
              	roomids.item(j).checked = true;  
              }   
              else{
              	roomids.item(j).checked = false;  
              }   
          }  
        }
        function synPermission(roleId){
	        var f=document.forms[0];
			f.action="common.do?method=synchronPermission&id="+roleId;
			f.submit();
        }  
        function roleGrant(){
	        var f=document.forms[0];
			f.action="role.do?method=roleGrant";
			f.submit();
        }
		</script>
  </html:form>
  </body>
</html:html>
